//
//  DJTableViewCell.m
//  CoolFM
//
//  Created by 曹曹 on 16/8/31.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "DJTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Dj_Info.h"
#import "UIView+Frame.h"

@interface DJTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *djImageView;
@property (weak, nonatomic) IBOutlet UILabel *djTitle;
@property (weak, nonatomic) IBOutlet UILabel *djDetail;
@property (weak, nonatomic) IBOutlet UILabel *djFollow;
@property (weak, nonatomic) IBOutlet UIImageView *iconImageView;

@end

@implementation DJTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)layoutSubviews {
    [super layoutSubviews];
}

- (void)setInfo:(Dj_Info *)info {
    _djFollow.text = [NSString stringWithFormat:@"人气: %ld", info.dj_popularity];
    if (info.dj_popularity > 999) {
        NSInteger single = info.dj_popularity / 10000;
        NSInteger deciml = info.dj_popularity % 10000 / 1000;
        NSString *num = [NSString stringWithFormat:@"%ld.%ld", single, deciml];
        _djFollow.text = [NSString stringWithFormat:@"人气: %@万", num];
    }
    _djTitle.text = info.dj_name;
    _djDetail.text = info.dj_summary;
    [_djImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", info.dj_image_url]]
                    placeholderImage:[UIImage imageNamed:@"img_dj_head"]
                           completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
                               _djImageView.layer.cornerRadius = _djImageView.bounds.size.width / 2.0;
                               _djImageView.layer.masksToBounds = YES;
     }];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
